package com.fsquare.controller.entity;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.broadleafcommerce.openadmin.web.controller.entity.AdminBasicEntityController;
import org.broadleafcommerce.openadmin.web.form.component.ListGrid;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.fsquare.service.invoice.InvoiceService;


@Controller("fsquareAdminCurrencyController")
@RequestMapping("/" + AdminCurrencyController.SECTION_KEY)
public class AdminCurrencyController extends AdminBasicEntityController {
	protected static final Log LOG = LogFactory.getLog(AdminCurrencyController.class);
	protected static final String SECTION_KEY = "currency";

	@Override
    protected String getSectionKey(Map<String, String> pathVars) {
        //allow external links to work for ToOne items
        if (super.getSectionKey(pathVars) != null) {
            return super.getSectionKey(pathVars);
        }
        return SECTION_KEY;
    }
	
    @RequestMapping(value = "", method = RequestMethod.GET)
    public String viewEntityList(HttpServletRequest request, HttpServletResponse response, Model model,
            @PathVariable  Map<String, String> pathVars,
            @RequestParam  MultiValueMap<String, String> requestParams) throws Exception {
        String retString = super.viewEntityList(request, response, model, pathVars, requestParams);
        
        
        ListGrid listGrid = (ListGrid) model.asMap().remove("listGrid");
        listGrid.setHideIdColumn(false);
        model.addAttribute("listGrid", listGrid);
        
        return retString;
//        List<Category> parentCategories = catalogService.findAllParentCategories();
//        model.addAttribute("parentCategories", parentCategories);
//        
//        List<EntityFormAction> mainActions = (List<EntityFormAction>) model.asMap().get("mainActions");
//        
//        mainActions.add(new EntityFormAction("CategoryTreeView")
//            .withButtonClass("show-category-tree-view")
//            .withDisplayText("Category_Tree_View"));
//        
//        mainActions.add(new EntityFormAction("CategoryListView")
//            .withButtonClass("show-category-list-view active")
//            .withDisplayText("Category_List_View"));
//        
//        model.addAttribute("viewType", "categoryTree");
//        return "modules/defaultContainer";
    }
}
